package com.huawei.recursion;

/**
 * @Description: 汉诺塔
 * @Author: GaoJian
 * @Date: 2022/7/9 02:55
 */
public class TowerOfHanoi {
    public static void main(String[] args) {
        hanoi(3, "A", "B", "C");
    }
    public static void hanoi(int n, String from, String middle, String to) {
        if (n < 2) {
            System.out.println(from + ">>>" + to);
        } else {
            hanoi(n - 1, from, to, middle);
            System.out.println(from + ">>>" + to);
            hanoi(n - 1, middle, from , to);
        }
    }
}
